<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
    <base href="/oa1/" />
    <title>襄阳蓝芯智能化办公系统 - 客户详情</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="static/bootstrap-3.3.5/css/bootstrap.css" rel="stylesheet">
    <style>
        /* 保持原有样式不变 */
        .thead-blue {
            color: #fff;
            font-weight: bold;
            background-color: #337ab7;
        }
    </style>
</head>
<body>

<!-- 1. 客户基本信息面板（保持原有结构，动态回显数据） -->
<div class="panel panel-primary">
    <table class="table table-bordered table-hover">
        <thead>
        <tr class="thead-blue">
            <td colspan="4">意向客户详情</td>
        </tr>
        </thead>
        <tbody>
        <!-- 客户名称 + 客户电话 -->
        <tr>
            <td class="col-md-2"><label>客户名称</label></td>
            <td class="col-md-4">${khCustomer.customerName}</td> <!-- 动态回显客户名称 -->
            <td class="col-md-2"><label>客户电话</label></td>
            <td class="col-md-4">${khCustomer.phone}</td> <!-- 动态回显客户电话 -->
        </tr>
        <!-- 公司性质 + 所属行业（数字转文字） -->
        <tr>
            <td><label>公司性质</label></td>
            <td>
                <!-- 公司性质：1=国有，2=外资，3=合资，4=私营 -->
                <c:choose>
                    <c:when test="${khCustomer.companyType == 1}">国有</c:when>
                    <c:when test="${khCustomer.companyType == 2}">外资</c:when>
                    <c:when test="${khCustomer.companyType == 3}">合资</c:when>
                    <c:when test="${khCustomer.companyType == 4}">私营</c:when>
                    <c:otherwise>未设置</c:otherwise>
                </c:choose>
            </td>
            <td><label>所属行业</label></td>
            <td>
                <!-- 所属行业：1=制造业，2=娱乐业，3=IT业，4=教育，5=外贸 -->
                <c:choose>
                    <c:when test="${khCustomer.vocation == 1}">制造业</c:when>
                    <c:when test="${khCustomer.vocation == 2}">娱乐业</c:when>
                    <c:when test="${khCustomer.vocation == 3}">IT业</c:when>
                    <c:when test="${khCustomer.vocation == 4}">教育</c:when>
                    <c:when test="${khCustomer.vocation == 5}">外贸</c:when>
                    <c:otherwise>未设置</c:otherwise>
                </c:choose>
            </td>
        </tr>
        <!-- 客户地区 + 客户地址 -->
        <tr>
            <td><label>客户地区</label></td>
            <td>${khCustomer.city != null ? khCustomer.city : '未设置'}</td> <!-- 判空处理 -->
            <td><label>客户地址</label></td>
            <td>${khCustomer.address != null ? khCustomer.address : '未设置'}</td>
        </tr>
        <!-- 客户邮编 + 客户传真 -->
        <tr>
            <td><label>客户邮编</label></td>
            <td>${khCustomer.zipcode != null ? khCustomer.zipcode : '未设置'}</td>
            <td><label>客户传真</label></td>
            <td>${khCustomer.fax != null ? khCustomer.fax : '未设置'}</td>
        </tr>
        <!-- 客户邮箱 + 单位网站 -->
        <tr>
            <td><label>客户邮箱</label></td>
            <td>${khCustomer.email != null ? khCustomer.email : '未设置'}</td>
            <td><label>单位网站</label></td>
            <td>${khCustomer.url != null ? khCustomer.url : '未设置'}</td>
        </tr>
        <!-- 开户行 + 银行账号 -->
        <tr>
            <td><label>开户行</label></td>
            <td>${khCustomer.bank != null ? khCustomer.bank : '未设置'}</td>
            <td><label>客户银行账号</label></td>
            <td>${khCustomer.account != null ? khCustomer.account : '未设置'}</td>
        </tr>
        <!-- 客户信用 + 客户介绍（新增介绍展示） -->
        <tr>
            <td><label>客户信用</label></td>
            <td colspan="1">
                <!-- 客户信用：1=良好，2=一般，3=较差 -->
                <c:choose>
                    <c:when test="${khCustomer.credit == 1}">良好</c:when>
                    <c:when test="${khCustomer.credit == 2}">一般</c:when>
                    <c:when test="${khCustomer.credit == 3}">较差</c:when>
                    <c:otherwise>未设置</c:otherwise>
                </c:choose>
            </td>
            <td><label>客户介绍</label></td>
            <td>${khCustomer.introduce != null ? khCustomer.introduce : '未设置'}</td>
        </tr>
        </tbody>
    </table>
</div>

<!-- 2. 新增：客户联系人列表面板（保持与基本信息面板风格一致） -->
<div class="panel panel-primary" style="margin-top: 15px;">
    <table class="table table-bordered table-hover">
        <thead>
        <tr class="thead-blue">
            <td colspan="6">客户联系人信息</td>
        </tr>
        <tr class="thead-blue">
            <td class="col-md-2">联系人姓名</td>
            <td class="col-md-2">职位</td>
            <td class="col-md-2">联系电话</td>
            <td class="col-md-2">电子邮箱</td>
            <td class="col-md-2">联系地址</td>
            <td class="col-md-2">邮政编码</td>
        </tr>
        </thead>
        <tbody>
        <!-- 循环回显联系人列表，无联系人时显示提示 -->
        <c:choose>
            <c:when test="${not empty contacts}">
                <c:forEach items="${contacts}" var="contact">
                    <tr>
                        <td>${contact.contactName}</td>
                        <td>${contact.job != null ? contact.job : '未设置'}</td>
                        <td>${contact.phone}</td>
                        <td>${contact.email != null ? contact.email : '未设置'}</td>
                        <td>${contact.address != null ? contact.address : '未设置'}</td>
                        <td>${contact.zipcode != null ? contact.zipcode : '未设置'}</td>
                    </tr>
                </c:forEach>
            </c:when>
            <c:otherwise>
                <tr>
                    <td colspan="6" align="center" style="color: #999;">暂无联系人信息</td>
                </tr>
            </c:otherwise>
        </c:choose>
        <!-- 返回按钮行 -->
        <tr>
            <td colspan="6" align="center">
                <a type="button" href="javascript:history.back()" class="btn btn-info">返回</a>
            </td>
        </tr>
        </tbody>
    </table>
</div>

<!-- 保持原有AJAX错误处理 -->
<script type="text/javascript">
    $(document).ajaxError(function(event,xhr) {
        if(xhr.status=="403"){// 无权限跳转
            document.location.href = xhr.getResponseHeader("url");
        }else if(xhr.status!="200"){// 服务器错误提示
            console.log("服务器错误!");
        }
    });
</script>
</body>
</html>